﻿Imports System.Drawing.Drawing2D

Module Skin_Class
    Private mBackBorderColor As Color = Color.FromArgb(255, 152, 76, 220)
    Private mBackColor1 As Color = Color.FromArgb(61, 116, 58)
    Private mBackColor2 As Color = Color.FromArgb(24, 114, 26)
    Private mBackcolor3 As Color = Color.FromArgb(61, 116, 58)
    Public Function DrawFormButtonMode(ByVal ImgWidth As Integer, ByVal ImgHeight As Integer, ByVal nEvent As ENUMMOUSEEVENT) As Bitmap
        If ImgWidth <= 0 Or ImgHeight <= 0 Then Return Nothing
        Dim _BackBorderColor As Color, _BackColor1, _BackColor2, _BackColor3 As Color
        Select Case nEvent
            Case ENUMMOUSEEVENT.MOUSENORMAL
                _BackBorderColor = mBackBorderColor
                _BackColor1 = mBackColor1
                _BackColor2 = mBackColor2
                _BackColor3 = mBackcolor3
            Case ENUMMOUSEEVENT.MOUSEHOVER
        End Select
        Dim img As New Bitmap(ImgWidth, ImgHeight), L As Integer
        Dim g As Graphics = Graphics.FromImage(img)
        L = img.Height - 1
        Dim TmpRect As New Rectangle(0, 0, L, L)
        g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
        Dim dPath As GraphicsPath = New GraphicsPath(FillMode.Alternate)
        Dim Bbrush As New LinearGradientBrush(New Rectangle(0, 0, img.Width, img.Height), _BackColor1, _BackColor2, LinearGradientMode.Vertical)
        Dim ColorB As New ColorBlend
        ColorB.Colors = New Color() {_BackColor1, _BackColor2, _BackColor3}
        ColorB.Positions = New Single() {0 / 2.0F, 1 / 2.0F, 3 / 3.0F}
        Bbrush.InterpolationColors = ColorB
        dPath.AddArc(TmpRect, 90.0F, 180.0F)
        dPath.AddLine(New Point(L / 2, 0), New Point(img.Width - L / 2 - 1, 0))
        TmpRect.X = img.Width - L - 1
        dPath.AddArc(TmpRect, 270.0F, 180.0F)
        dPath.AddLine(New Point(img.Width - L / 2 - 1, img.Height - 1), New Point(L / 2, img.Height - 1))
        g.FillPath(Bbrush, dPath)
        g.DrawPath(New Pen(_BackBorderColor), dPath)
        Bbrush.Dispose()
        dPath.Dispose()
        g.Dispose()
        Return img
        '  DrawBP(Me, img, 255)
    End Function
    Public Function CreateRoundPath(ByVal Rect As Rectangle, ByVal R As Integer)
        Dim ResultPath As GraphicsPath = New GraphicsPath(FillMode.Alternate)
        Dim L As Integer = 2 * R
        Dim TmpRect As Rectangle = New Rectangle(Rect.Location, New Size(L, L))
        With ResultPath
            .AddArc(TmpRect, 180.0F, 90.0F)
            .AddLine(New Point(Rect.Left + R, Rect.Top), New Point(Rect.Right - R, Rect.Top))
            TmpRect.X = Rect.Right - L
            .AddArc(TmpRect, 270.0F, 90.0F)
            .AddLine(New Point(Rect.Right, Rect.Top + R), New Point(Rect.Right, Rect.Bottom - R))
            TmpRect.Y = Rect.Bottom - L
            .AddArc(TmpRect, 0.0F, 90.0F)
            .AddLine(New Point(Rect.Right - R, Rect.Bottom), New Point(Rect.Left + R, Rect.Bottom))
            TmpRect.X = Rect.Left
            .AddArc(TmpRect, 90.0F, 90.0F)
            .AddLine(New Point(Rect.Left, Rect.Bottom - R), New Point(Rect.Left, Rect.Top + R))
            Return ResultPath
        End With
    End Function
End Module
